﻿#region COPYRIGHT
//--------------------------------------------------------------------------------
// <copyright file="SplashScreenGame.cs" company="starLiGHT Entertainment Studios">
//    Copyright (c) 2010 
//       Roland Rosenkranz (Glatzemann@email.de)
// </copyright>
// <license>
//   This file is part of starLiGHT.Core.
//
//   starLiGHT.Core is free software: you can redistribute it and/or modify
//   it under the terms of the GNU Lesser General Public License as published by
//   the Free Software Foundation, either version 3 of the License, or
//   (at your option) any later version.
//
//   starLiGHT.Core is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU Lesser General Public License for more details.
//
//   You should have received a copy of the GNU Lesser General Public License
//   along with starLiGHT.Core. If not, see http://www.gnu.org/licenses/.
//    
//   ADDITIONAL (commercial) LICENSES for starLiGHT.Core are available on request.
// </license>
// <version>
// **************[ starLiGHT.Engine SVN ]**********************
// * $Rev:: 2845                  $:  Revision of last commit *
// * $Author:: unknown            $:  Author of last commit   *
// * $Date:: 2010-12-30 13:03:57 #$:  Date of last commit     *
// ************************************************************
// </version>
//--------------------------------------------------------------------------------
#endregion

namespace starLiGHT.Game
{
    #region Using Statements
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Content;
    using Microsoft.Xna.Framework.Graphics;
    using starLiGHT;
    #endregion

    public class SplashScreenGame : Microsoft.Xna.Framework.Game
    {
        protected readonly string SplashScreenName = "SplashScreen";

        public SplashScreenGame()
            : base()
        {
        }

        public SplashScreenGame(string splashScreenName)
            : base()
        {
            this.SplashScreenName = splashScreenName;
        }

        protected override void Initialize()
        {
            base.Initialize();

            Texture2D splashScreen = null;
            try
            {
                splashScreen = Content.Load<Texture2D>(this.SplashScreenName);
            }
            catch (ContentLoadException)
            {
                // Ignore this exception... splash screen is not available, so simply don't render it
            }
            finally
            {
                if (splashScreen != null)
                {
                    SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice);

                    spriteBatch.Begin();
                    spriteBatch.Draw(splashScreen, new RectangleF(Vector2.Zero, GraphicsDevice.Viewport.GetSize()), Color.White);
                    spriteBatch.End();

                    GraphicsDevice.Present();
                }
            }
        }
    }
}
